import { generateResponseList } from './tools'

/**
 * @param {import('mockjs')} Mock
 */
export function getList(Mock) {
  Mock.mock('/cartList', options => {
    const data = JSON.parse(options.body)

    return Mock.mock({
      'list|10': [
        {
          title: Mock.Random.title(3, 5),
          address: Mock.Random.county(true),
          img: Mock.Random.image('200x100'),
          time: Mock.Random.datetime()
        }
      ],
      ...generateResponseList(Mock, data)
    })
  })
}
